package obj;

import UI.control;


import javax.swing.*;
/**
 *飞行物类：
 * 血条
 * 飞行速度
 * 移动位置 返回是否移动成功
 */


public class player implements objs{
    public int x;
    public int y;
    private int speed;
    public long Last_shoot;
    public int wid=40;
    public int hei=40;
    private int Life;
    private ImageIcon img;
    public player(int x,int y,int speed,int Life){
        this.x=x;
        this.y=y;
        this.img=new ImageIcon("E:\\java\\month3-game\\resource\\plant2.png");
        this.speed=speed;
        this.Life=Life;
    }
    public player(int x,int y,int speed,int Life,String path){
        this.x=x;
        this.y=y;
        this.img=new ImageIcon(path);
        this.speed=speed;
        this.Life=Life;
    }
    public void setSize(int wid,int hei){
        this.wid=wid;
        this.hei=hei;
    }
    @Override
    public ImageIcon GetImg() {
        return this.img;
    }

    @Override
    public int Getx() {
        return this.x;
    }

    @Override
    public int Gety() {
        return this.y;
    }

    @Override
    public int getspeed() {
        return this.speed;
    }
    public boolean move(int dx,int dy){
        if(x+dx<control.width-40&&x+dx>=0){
            this.x+=dx;
            if(y+dy<control.heigth-40&&y+dy>=0){
                this.y+=dy;
            }
            //没越界返回ture

            return true;
        }
        else
            return false;
    }

    @Override
    public int GetWid() {
        return this.wid;
    }

    @Override
    public int GetHei() {
        return this.hei;
    }

    public void changeLife(int de){
        this.Life+=de;
    }
    public boolean IsDie(){
        /**
         * 死亡返回true
         * 存活返回false
         */
        if(this.Life<=0)
            return true;
        else
            return false;
    }
    public int GetLife(){
        return this.Life;
    }
}
